package com.tang.Dao;
import com.tang.pojo.Order;

import java.util.List;

public class OrderDao {
    public void saveOrder(double price,String createTime,int status,int userId){
        String sql="insert into t_order(price,createTime,status,userId) values(?,?,?,?);";
        BaseDao bd =new BaseDao();
        Order order=new Order(null,price,createTime,status,userId);
        bd.update(sql,order.getPrice(),order.getCreateTime(),order.getStatus(),order.getUserId());
    }
    public Order queryIdByTime(String time){
        String sql="select * from t_order where createTime=?;";
        BaseDao bd=new BaseDao();
        return bd.queryforOne(Order.class,sql,time);
    }
    public List<Order> queryAllOrders(){
        BaseDao bd=new BaseDao();
        String sql="select * from t_order;";
        return bd.queryforMul(Order.class,sql);
    }
    public void sendOrder(int id){
        String sql="update t_order set status=1 where id=?;";
        BaseDao bd=new BaseDao();
        bd.update(sql,id);
    }
    public List<Order> queryByUserID(int userID){
        BaseDao bd=new BaseDao();
        String sql="select * from t_order where userId=?;";
        return bd.queryforMul(Order.class,sql,userID);
    }
    public void receive(int id){
        String sql="update t_order set status=2 where id=?;";
        BaseDao bd=new BaseDao();
        bd.update(sql,id);
    }
}
